<?php
/**
 * @package		Joomla
 * @subpackage	Templates
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access.
defined('_JEXEC') or die;

$document			= JFactory::getDocument();

// entferne MooTools; @todo core.js mit JQuery nachbauen; @todo als Plugin auslagern
unset($document->_scripts['/media/system/js/mootools-core.js']);
unset($document->_scripts['/media/system/js/core.js']);
unset($document->_scripts['/media/system/js/caption.js']);
unset($document->_script['text/javascript']);

$hash  = $this->baseurl . '/templates/' . $this->template . '/javascript/jcarousel-0.2.8.js';
$hash .= $this->baseurl . '/templates/' . $this->template . '/javascript/fancybox-min-2.0.6.js';
$hash .= $this->baseurl . '/templates/' . $this->template . '/javascript/jplain.js';

$hash	= md5($hash);

JResponse::clearHeaders();
JResponse::allowCache(true);

JResponse::setHeader('Etag', $hash, true);
JResponse::setHeader('Cache-Control', 'private, must-revalidate', true);
JResponse::setHeader('Content-Type', 'text/javascript', true);

if(isset($_SERVER['HTTP_IF_NONE_MATCH']) === true && $_SERVER['HTTP_IF_NONE_MATCH'] == $hash) {
	header('HTTP/1.1 304 Not Modified');
	header('Connection: Close');
	exit();
}

$data  = JFile::read(JPATH_BASE . '/templates/' . $this->template . '/javascript/fancybox-min-2.0.6.js');
$data .= JFile::read(JPATH_BASE . '/templates/' . $this->template . '/javascript/jcarousel-0.2.8.js');
$data .= JFile::read(JPATH_BASE . '/templates/' . $this->template . '/javascript/jplain.js');

JResponse::setBody($data);

echo JResponse::toString();
exit();

?>